{% extends "analysis_plugins/general_information.html" %}

{% block analysis_result_details %}

{% set analysis = analysis_result['Output'] %}
{% for key in analysis.keys() | sort %}
    <tr>
        <td>
            {{ key }}
        </td>
        <td class="m-0 p-0">
            <div class="clickable pt-2 pl-3" data-toggle="collapse" data-target="#{{ key }}">
                <i class="fas fa-angle-down mb-2 pt-2"></i>
            </div>

            <div class="collapse w-100" id="{{ key }}">
                <table class="table table-bordered mb-0 pb-0">
                    {% if analysis[key] | is_list %}
                        {% if not analysis[key] %}
                            <tr>
                                <td style="padding: 5px">None</td>
                            </tr>
                        {% elif analysis[key][0] is string %}
                                {% for element in analysis[key] %}
                                    <tr>
                                        <td style="padding: 5px">{{ element }}</td>
                                    </tr>
                                {% endfor %}
                        {% else %}
                            <tr>
                                {% for unique_key in analysis[key] | get_unique_keys_from_list_of_dicts | sort %}
                                    <th style="padding: 5px">{{ unique_key }}</th>
                                {% endfor %}
                            </tr>
                            {% for dictionary in analysis[key] %}
                                <tr>
                                    {% for unique_key in analysis[key] | get_unique_keys_from_list_of_dicts | sort %}
                                        {% if unique_key in dictionary.keys() %}
                                            <td style="padding: 5px">{{ dictionary[unique_key] }}</td>
                                        {% else %}
                                            <td></td>
                                        {% endif %}
                                    {% endfor %}
                                </tr>
                            {% endfor %}
                        {% endif %}
                    {% elif analysis[key] %}
                        {% for k, v in analysis[key].items() %}
                            <tr>
                                <td style="padding: 5px">{{ k }}</td>
                                <td style="padding: 5px">{{ v }}</td>
                            </tr>
                        {% endfor %}
                    {% endif %}

                </table>
            </div>

        </td>
    </tr>
{% endfor %}

{% endblock %}
